CUBE CONNECT Edition Help

CubeAPI Classes Summary

The below table provides a summary of the main classes that the CubeAPI provides. This list is not fully comprehensive but is intended to introduce the main components of the API and their functionalities.

Utility Category CubePy Class Description
CUBE Network / CUBE Database BNFSConfig

This class allows to create a new CUBE SQLite network by importing a network from an ESRI shape file.

For node numbering, the user can use existing node numbers from the shape file or create new numbers.

If the existing numbers should be used and both the node and link files are provided, an attribute called N should store the node number and two attributes named A and B should be included in the links Shape File, with the correspondence to N.

CubeDatabase and derived objects

This class provides the capability of creating a new, opening an existing, and working with a CUBE database. Currently a CUBE database is a Spatialite or PostGIS database. The CubeDatabase class can create Spatialite databases but it cannot create a PostgreSQL/PostGIS database; it is required that the user creates the PostGIS database prior to its use within the CubeAPI.

The CubeDatabase class allows to:

• Create new CUBE networks or edit existing networks.

• Interrogate and edit the database content and its data and metadata.

• Generate statistics and diagnostics for CUBE networks links and nodes contained in the database.

• Generate network topology information.

• Manipulate CUBE networks with the possibility to automatically add centroid connectors through an inbuilt algorithm, add or edit link and node attributes.

• Renumber nodes, updating other network synced datasets.

• Calculate shortest path through the network.

• Associating and editing Public Transport data to a CUBE network, and Non-Transit networks, junctions data and turn penalties, tolls data.

• Perform the Build Network From Shape operations.

Methods provided by the CubeDatabase class, whose names start with the “value” string, support the usage of Lua Expressions for generating statistics, but also to add attributes or updates attributes. These expressions allow to very efficiently manipulate links or nodes, with just one line of Python script and few lines of Lua expressions.

The user may access the tables stored in CUBE databases directly from other applications outside of the CubeAPI. However, the data should not be modified without using the CubeAPI due to risks of corrupting or invalidating the data for use within CUBE.

CUBE Matrix CubeMatrixFile and derived objects

This class allows to open an existing CUBE matrix file (*.cube-matrix file) or to create a new CUBE matrix and save it to file.

Available methods for this class include:

• Open an existing CUBE matrix file.

• Create a new CUBE matrix file.

• Add a new matrix to a new or existing CUBE matrix file.

• Remove a matrix from a matrix file.

• Obtain the matrix attributes, such as number of matrices inside the matrix file, names, check existence of matrix names, obtain number of zones, size of the matrix file.

• Add, remove and modify zonal references.

• Transpose matrices.

addMatrix() and Matrix() methods returns a CubeMatrix object.

Ref. example

Connecting to a matrix with the CubeMatrix.

CubeMatrix

A CUBE Matrix File is needed, generating a CubeMatrix object.

This class provides all the methods to process CUBE matrix files:

• To read and write matrix data with different compression levels (note below) , including seaming less interface with NumPy multi-dimensional arrays.

• To obtain matrix metadata, matrix statistics such a grand totals, minimum, maximum, non zero counts, intrazonal statistics, etc.

• To obtain columns and rows statistics, such as trip ends, rows and columns averages, sum of n lowest values (sum of lowest n cells, with low and high limits, excluding specific cells), maximums, minimums, non-zero counts, non-zero averages and non-zero minimums, etc.

• Adding scalars to matrix.

The default compression level is 0 (no-compression). The suggested compression level is 1 for large matrices. Higher compression levels can cause an increase in runtime with no major benefit in terms of file size.